package wanbang.service.Imp;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import wanbang.dao.BookDao;
import wanbang.dao.CartDao;
import wanbang.entities.Cart;
import wanbang.service.ShowCartService;
@Service
public class ShowCartServiceImp implements ShowCartService {
	@Autowired
	private CartDao cartDao;
	@Autowired
	private BookDao bookDao;

	@Override
	public List<Cart> selectAllCart(Integer userId) {
		// TODO Auto-generated method stub
		List<Cart> carts = this.cartDao.selectAllCart(userId);
		for(Cart cart : carts) {
			cart.setBook(this.bookDao.selectBybookId(cart.getBookId()));
		}
		return carts;
	}

}
